<?php
$engine = trim($_REQUEST['engine']);
$keyWord = trim($_REQUEST['keyWord']);
if(strlen($engine)>0&&strlen($keyWord)>0){
	$keyWord = urlencode($keyWord);
	$url = NULL;
	$timeNow = time();
	$timeNow = (string)$timeNow;
	if($engine == "google"){
		$url = "http://www.google.com/complete/search?hl=zh-CN&xhr=t&t=".$timeNow."&q=".$keyWord;
	}else if($engine == "baidu"){
		$url = "http://suggestion.baidu.com/su?t=".$timeNow."&q=".$keyWord;
	}else if($engine == "bing"){
		$url = "http://api.bing.net/qsonhs.aspx?mkt=zh-CN&t=".$timeNow."&q=".$keyWord;
	}

	$curl = curl_init($url);
	curl_setopt($curl,CURLOPT_FAILONERROR,1); // 告诉cUrl如果出现异常则失败
	curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); // 将返回值指向一个变量
	$result = curl_exec($curl);
	curl_close($curl);
	echo $result;
}
?>